﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace The_LarX
{
    public static class Vector2Util
    {
        /// <summary>
        /// Returns X + Y / 2
        /// </summary>
        /// <param name="vec"></param>
        /// <returns></returns>
        public static float Average(Vector2 vec)
        {
            return (vec.X + vec.Y) / 2;
        }

        /// <summary>
        /// Returns a Half Vector2 (0.5f, 0.5f)
        /// </summary>
        /// <returns></returns>
        public static Vector2 Half
        {
            get { return new Vector2(0.5f, 0.5f); }
        }

        /// <summary>
        /// Calculates the Angle of the Gaven direction. Credits goes to XNA Wiki
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        public static float ToAngle(Vector2 direction)
        {
            return (float)Math.Atan2(direction.Y, direction.X);
        }

        public static Vector2 Vector3ToVector2(Vector3 vec)
        {
            return new Vector2(vec.X, vec.Y);
        }
    }
}
